﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPF基础.控件
{
    /// <summary>
    /// A13_Combobox.xaml 的交互逻辑
    /// </summary>
    public partial class A13_Combobox : Window
    {
        public A13_Combobox()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //使用item
            //this.Combox_1.Items.Add("Python");
            //this.Combox_1.Items.Add("C#");
            //this.Combox_1.Items.Add("Go");
            //this.Combox_1.Items.Add("Ruby");

            //使用datacontext 进行绑定
            List<A13_ClassInfo> Class = new List<A13_ClassInfo>();
            Class.Add(new A13_ClassInfo() { ClassName = "高三一班", Code = "301" });
            Class.Add(new A13_ClassInfo() { ClassName = "高三二班", Code = "302" });
            Class.Add(new A13_ClassInfo() { ClassName = "高三三班", Code = "303" });
            this.Combox_1.DataContext = Class;
            this.Combox_1.DisplayMemberPath = "ClassName";
            this.Combox_1.SelectedValuePath = "Code";
        }
    }
}
